package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.weixin.WeixinUtil;
import com.ruoyi.common.utils.weixin.po.AccessToken;
import com.ruoyi.common.utils.weixin.po.AccessUser;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.system.domain.WxCode;
import com.ruoyi.system.domain.WxSendMsgLog;
import com.ruoyi.system.domain.WxUser;
import com.ruoyi.system.service.IWeixinService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * 微信模块管理
 * @author admin
 *
 */
@Controller
@RequestMapping("/system/wxSendMsgLog")
public class WxSendMsgLogController extends BaseController{
	
	private String prefix = "system/wxsendmsglog";
	
	@Autowired
	private IWeixinService weixinService;
	
	/**
	 * 视图页面展示
	 * @return
	 */
	@RequiresPermissions("system:wxSendMsgLog:view")
    @GetMapping()
    public String index(){
        return prefix + "/index";
    }
	
	/**
	 * 微信发送日志列表页数据
	 * @param sendLog
	 * @return
	 */
	@RequiresPermissions("system:wxSendMsgLog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WxSendMsgLog sendLog){
        startPage();
        List<WxSendMsgLog> list = weixinService.selectWxSendMsgLogList(sendLog);
        return getDataTable(list);
    }

	@RequiresPermissions("system:wxSendMsgLog:remove")
	@Log(title = "群发消息管理", businessType = BusinessType.DELETE)
	@PostMapping("/remove")
	@ResponseBody
	public AjaxResult remove(String ids){
		try{
			return toAjax(weixinService.deleteWxSendMsgLogByIds(ids));
		} catch (Exception e){ return error(e.getMessage()); }
	}

}
